package cn.itchao.example.member.controller;

import cn.itchao.example.goods.domain.Goods;
import cn.itchao.example.member.service.MemberService;
import cn.itchao.exmaple.base.ApiResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RestController;

@RestController
public class MemberController {

    @Autowired
    private MemberService memberService;

    @GetMapping("/member/goods/dubbo/{id}")
    public ApiResponse findGoodsById(@PathVariable("id") Long id){
        Goods goods = memberService.findGoodsById(id);
        return ApiResponse.ofSuccess(goods);
    }

    @GetMapping("/member/goods/rest/{id}")
    public ApiResponse findGoodsRestById(@PathVariable("id") Long id){
        Goods goods = memberService.findGoodsRestById(id);
        return ApiResponse.ofSuccess(goods);
    }

    @GetMapping("/member/goods/dubbo/rest/{id}")
    public ApiResponse findGoodsDubboRestById(@PathVariable("id") Long id){
        Goods goods = memberService.findGoodsDubboRestById(id);
        return ApiResponse.ofSuccess(goods);
    }
}
